define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'todo/bank/index' + location.search,
                    //add_url: 'todo/bank/add',
                    //edit_url: 'todo/bank/edit',
                   // del_url: 'todo/bank/del',
                    multi_url: 'todo/bank/multi',
                    import_url: 'todo/bank/import',
                    table: 'xiservice_user',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
                        {field: 'contact_name', title: __('Username'), operate: 'LIKE'},
                        {field: 'avatar', title: __('Avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
                        //{field: 'contact_name', title: __('Contact_name'), operate: 'LIKE'},
                        {field: 'citytxt', title: __('Citytxt'), operate: 'LIKE'},
                        {field: 'sq_price', title: __('Sq_price'), operate:'BETWEEN'},
                        {field: 'tk_ret', title: __('Tk_ret'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        //{field: 'tk_type', title: __('Tk_type')},
                        // {field: 'tk_type', title: __('保证金退款申请'), searchList: {"1":__('已申请'),"2":__('未申请')}, formatter: Table.api.formatter.tk_type},
                        {field: 'tk_type', title: __('保证金退款申请'), searchList: {"1":__('已申请'),"2":__('未申请')}, formatter: Table.api.formatter.normal},
                        {field: 'bank', title: __('Bank'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'bank_addr', title: __('Bank_addr'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'tk_image', title: __('Tk_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, buttons: [
                            {
                                name: 'addtabs',
                                text: __('同意'),
                                title: __('上传凭证'),
                                classname: 'btn btn-xs btn-warning  btn-dialog',
                                // icon: 'fa fa-eye',
                                url: 'todo/bank/edit?ids={id}', 
                                refresh:true,
                                    visible:function(row){
                                        if(row.is_bzje_sq==1){
                                             return true;
                                        }
                                        return false;
                                    }
                            },

                        ],formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        // add: function () {
        //     Controller.api.bindevent();
        // },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
